﻿class Preloader
{
	private var _sourceClip : MovieClip
	private var bar_mc : MovieClip;
	private var percent_txt:TextField;
	public function Preloader ()
	{
		this._sourceClip = _root;
		this.bar_mc._width = 1
	}
	public function set sourceClip (mc : MovieClip):Void
	{
		this._sourceClip = mc;
	}
	private function onEnterFrame ():Void
	{
		var percent = Math.round(this._sourceClip.getBytesLoaded()/this._sourceClip.getBytesTotal()*100)
		this.bar_mc._width = percent;
this.percent_txt.text = percent + "%";
		trace ("Tracking Loading of  " + percent);
		if (percent >=100){
			trace("Killing on enterframe")
			onLoaded();
			this.onEnterFrame = null;
		}
	}
	public function onLoaded(){}
}
